home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / numerico.zip / NUMERIC.C < prev   
Text File  |  1993-04-06  |  38KB  |  1,059 lines

  1. /* *******************************************************************
  2.  * Function name : d_convert(string)
  3.  *
  4.  * Description   : This function converts a character string number
  5.  *                 into the actual numerical value.  This value,
  6.  *                 then being placed in a double floating point
  7.  *                 variable.
  8.  *
  9.  * Variables     : string - This variable is the vehicle used to
  10.  *                          receive the character string sent by the
  11.  *                          calling function.
  12.  *
  13.  *                 count  - This variable is used to assist in loop
  14.  *                          control
  15.  *
  16.  *                 sign   - This variable is set to 1 at the onset of
  17.  *                          the function. Then, if a negative sign is
  18.  *                          encountered in the number, "sign" is set
  19.  *                          to a value of -1. Finally, just prior to
  20.  *                          returning a numeric value, this value is
  21.  *                          multiplied by sign. This, if a negative sign
  22.  *                          was encountered, than the multiplication by
  23.  *                          -1 would make the returned value negative.
  24.  *
  25.  *                 digit - "digit" contains the individual character
  26.  *                         values to be converted.
  27.  *
  28.  *                period - This variable tracts the location of the
  29.  *                         decimal point.
  30.  *
  31.  * Examples      : char ascii_number[] = "123.45";
  32.  *                 double output, d_convert();
  33.  *                 output = d_convert(ascii_number);
  34.  *
  35.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  36.  *                 is converted as 123.
  37.  *
  38.  *                 The negative sign may be at either the beginning of
  39.  *                 ending of the input number.
  40.  *
  41.  *                 The function name "d_convert" must be defined as a
  42.  *                 "double" within the calling function.
  43.  *
  44.  */
  45.  
  46. double d_convert(string)
  47.  char string[];
  48. { int count, sign, digit, period;
  49.   double amount, point;
  50.   count = 0;
  51.   sign = 1;
  52.   while (string[count] )
  53.     if (string[count++] == '-' )  sign = -1;
  54.  
  55.   count = amount = period = 0;  point = 1;
  56.   while ( string[count] )
  57.    { if ( string[count] == '.' ) period = 1;
  58.      if ( string[count] >= '0' && string[count] <= '9' )
  59.        { digit = string[count] - '0';
  60.      amount *= 10;
  61.      amount += digit;
  62.      if ( period == 1 ) point *= .1;
  63.        }
  64.      count++;
  65.    }
  66.   amount *= point;
  67.   amount *= sign;
  68.   return(amount);
  69. }
  70.  
  71.  
  72. /* *******************************************************************
  73.  * Function name : f_convert(string)
  74.  *
  75.  * Description   : This function converts a character string number
  76.  *                 into the actual numerical value.  This value,
  77.  *                 then being placed in a floating point variable.
  78.  *
  79.  * Variables     : string - This variable is the vehicle used to
  80.  *                          receive the character string sent by the
  81.  *                          calling function.
  82.  *
  83.  *                 count  - This variable is used to assist in loop
  84.  *                          control
  85.  *
  86.  *                 sign   - This variable is set to 1 at the onset of
  87.  *                          the function. Then, if a negative sign is
  88.  *                          encountered in the number, "sign" is set
  89.  *                          to a value of -1. Finally, just prior to
  90.  *                          returning a numeric value, this value is
  91.  *                          multiplied by sign. This, if a negative sign
  92.  *                          was encountered, than the multiplication by
  93.  *                          -1 would make the returned value negative.
  94.  *
  95.  *                 digit - "digit" contains the individual character
  96.  *                         values to be converted.
  97.  *
  98.  *                period - This variable tracts the location of the
  99.  *                         decimal point.
  100.  *
  101.  * Examples      : char ascii_number[] = "123.45";
  102.  *                 float output, f_convert();
  103.  *                 output = f_convert(ascii_number);
  104.  *
  105.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  106.  *                 is converted as 123.
  107.  *
  108.  *                 The negative sign may be at either the beginning of
  109.  *                 ending of the input number.
  110.  *
  111.  *                 The function name "f_convert" must be defined as a
  112.  *                 "float" within the calling function.
  113.  *
  114.  */
  115.  
  116. float f_convert(string)
  117.  char string[];
  118. { int count, sign, digit, period;
  119.   float amount, point;
  120.   count = 0;
  121.   sign = 1;
  122.   while (string[count] )
  123.     if (string[count++] == '-' )  sign = -1;
  124.  
  125.   count = amount = period = 0;
  126.   point = 1;  while ( string[count] )
  127.    { if ( string[count] == '.' ) period = 1;
  128.      if ( string[count] >= '0' && string[count] <= '9' )
  129.        { digit = string[count] - '0';
  130.      amount *= 10;
  131.      amount += digit;
  132.      if ( period == 1 ) point *= .1;
  133.        }
  134.      count++;
  135.    }
  136.   amount *= point;
  137.   amount *= sign;
  138.   return(amount);
  139. }
  140.  
  141.  
  142. /* *******************************************************************
  143.  * Function name : i_convert(string)
  144.  *
  145.  * Description   : This function converts a character string number
  146.  *                 into the actual numerical value.  This value,
  147.  *                 then being placed in an integer variable.
  148.  *
  149.  * Variables     : string - This variable is the vehicle used to
  150.  *                          receive the character string sent by the
  151.  *                          calling function.
  152.  *
  153.  *                 count  - This variable is used to assist in loop
  154.  *                          control
  155.  *
  156.  *                 sign   - This variable is set to 1 at the onset of
  157.  *                          the function. Then, if a negative sign is
  158.  *                          encountered in the number, "sign" is set
  159.  *                          to a value of -1. Finally, just prior to
  160.  *                          returning a numeric value, this value is
  161.  *                          multiplied by sign. This, if a negative sign
  162.  *                          was encountered, than the multiplication by
  163.  *                          -1 would make the returned value negative.
  164.  *
  165.  *                 digit - "digit" contains the individual character
  166.  *                         values to be converted.
  167.  *
  168.  * Examples      : char ascii_number[] = "123.45";
  169.  *                 int output, f_convert();
  170.  *                 output = i_convert(ascii_number);
  171.  *
  172.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  173.  *                 is converted as 123.
  174.  *
  175.  *                 The negative sign may be at either the beginning of
  176.  *                 ending of the input number.
  177.  *
  178.  *                 The function name "i_convert" may optionally be
  179.  *                 defined as an integer within the calling function.
  180.  *
  181.  *                 Decimal points are ignored.
  182.  */
  183.  
  184. i_convert(string)
  185.  char string[];
  186. { int count, sign, amount, digit;
  187.   count = 0;
  188.   sign = 1;
  189.   while (string[count] )
  190.     if (string[count++] == '-' )  sign = -1;
  191.  
  192.   count = amount = 0;
  193.   while ( string[count] )
  194.    { if ( string[count] >= '0' && string[count] <= '9' )
  195.        { digit = string[count] - '0';
  196.      amount *= 10;
  197.      amount += digit;
  198.        }
  199.      count++;
  200.    }
  201.   amount *= sign;
  202.   return(amount);
  203. }
  204.  
  205. /* *******************************************************************
  206.  * Function name : lpr_char(x, y, string, outstring)
  207.  *
  208.  * Description   : This function facilitates the input of ASCII
  209.  *                 character strings. Additionally, prior the to actual
  210.  *                 input, the cursor is placed at a specified screen
  211.  *                 location and a prompt is displayed.
  212.  *
  213.  * Variables     : string - This variable is the vehicle used to
  214.  *                          receive the prompt that is displayed
  215.  *                          on the screen
  216.  *
  217.  *                 x      - This parameter defines the horizontal
  218.  *                          row on which the cursor will be placed.
  219.  *                          Consider "x" to be the "x" part of an
  220.  *                          "x,y" axis.
  221.  *
  222.  *                 y      - This parameter defines the vertical
  223.  *                          column on which the cursor will be placed.
  224.  *                          Consider "y" to be the "y" part of an
  225.  *                          "x,y" axis.
  226.  *
  227.  *              outstring - This variable contains the ASCII character
  228.  *                          character string input by the user.
  229.  *
  230.  *
  231.  * Examples      : char ascii_value[10];
  232.  *                 lpr_char(10,5,"Enter employee name : ",ascii_value);
  233.  *
  234.  * Rules         : Any ASCII characters can be entered.
  235.  *
  236.  *                 The "x" value must be between 1 and 24
  237.  *
  238.  *                 The "y" value must be between 1 and 80
  239.  *
  240.  */
  241.  
  242. lpr_char(x,y,string,out_string)
  243.  int x,y;
  244.  char string[], *out_string;
  245.  
  246. { printf("%c[%d;%dH",'\33',x,y);
  247.   printf("%s",string);
  248.   gets(out_string);
  249. }
  250.  
  251.  
  252. /* *******************************************************************
  253.  * Function name : lpr_double(x, y, string)
  254.  *
  255.  * Description   : This function facilitates the input of double floating
  256.  *                 point number. Additionally, prior the to actual
  257.  *                 input, the cursor is placed at a specified screen
  258.  *                 location and a prompt is displayed.
  259.  *
  260.  * Variables     : string - This variable is the vehicle used to
  261.  *                          receive the prompt that is displayed
  262.  *                          on the screen
  263.  *
  264.  *                 x      - This parameter defines the horizontal
  265.  *                          row on which the cursor will be placed.
  266.  *                          Consider "x" to be the "x" part of an
  267.  *                          "x,y" axis.
  268.  *
  269.  *                 y      - This parameter defines the vertical
  270.  *                          column on which the cursor will be placed.
  271.  *                          Consider "y" to be the "y" part of an
  272.  *                          "x,y" axis.
  273.  *
  274.  *
  275.  * Examples      : double output, lpr_double();
  276.  *                 output = lpr_double(10,5,"Enter employee name : ");
  277.  *
  278.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  279.  *                 is converted as 123.
  280.  *
  281.  *                 The negative sign may be at either the beginning of
  282.  *                 ending of the input number.
  283.  *
  284.  *                 The function name "lpr_double" must be defined
  285.  *                 as a double floating point number within the
  286.  *                 calling function.
  287.  *
  288.  *                 The "x" value must be between 1 and 24
  289.  *
  290.  *                 The "y" value must be between 1 and 80
  291.  *
  292.  */
  293.  
  294. double lpr_double(x,y,string)
  295.  int x,y;
  296.  char string[];
  297.  
  298. { double out_num, d_convert();
  299.   char in_num[15];
  300.   printf("%c[%d;%dH",'\33',x,y);
  301.   printf("%s",string);
  302.   gets(in_num);
  303.   out_num = d_convert(in_num);
  304.   return(out_num);
  305. }
  306.  
  307. /* *******************************************************************
  308.  * Function name : lpr_float(x, y, string)
  309.  *
  310.  * Description   : This function facilitates the input of floating
  311.  *                 point number. Additionally, prior the to actual
  312.  *                 input, the cursor is placed at a specified screen
  313.  *                 location and a prompt is displayed.
  314.  *
  315.  * Variables     : string - This variable is the vehicle used to
  316.  *                          receive the prompt that is displayed
  317.  *                          on the screen
  318.  *
  319.  *                 x      - This parameter defines the horizontal
  320.  *                          row on which the cursor will be placed.
  321.  *                          Consider "x" to be the "x" part of an
  322.  *                          "x,y" axis.
  323.  *
  324.  *                 y      - This parameter defines the vertical
  325.  *                          column on which the cursor will be placed.
  326.  *                          Consider "y" to be the "y" part of an
  327.  *                          "x,y" axis.
  328.  *
  329.  *
  330.  * Examples      : float output, lpr_float();
  331.  *                 output = lpr_float(10,5,"Enter employee name : ");
  332.  *
  333.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  334.  *                 is converted as 123.
  335.  *
  336.  *                 The negative sign may be at either the beginning of
  337.  *                 ending of the input number.
  338.  *
  339.  *                 The function name "lpr_float" must be defined
  340.  *                 as a double floating point number within the
  341.  *                 calling function.
  342.  *
  343.  *                 The "x" value must be between 1 and 24
  344.  *
  345.  *                 The "y" value must be between 1 and 80
  346.  *
  347.  */
  348.  
  349. float lpr_float(x,y,string)
  350.  int x,y;
  351.  char string[];
  352.  
  353. { float out_num, f_convert();
  354.   char in_num[15];
  355.   printf("%c[%d;%dH",'\33',x,y);
  356.   printf("%s",string);
  357.   gets(in_num);
  358.   out_num = f_convert(in_num);
  359.   return(out_num);
  360. }
  361.  
  362. /* *******************************************************************
  363.  * Function name : lpr_g_response(x, y, string)
  364.  *
  365.  * Description   : This function facilitates the input of a keyboard
  366.  *                 response. Additionally, prior the to actual
  367.  *                 input, the cursor is placed at a specified screen
  368.  *                 location and a prompt is displayed.
  369.  *
  370.  * Variables     : string - This variable is the vehicle used to
  371.  *                          receive the prompt that is displayed
  372.  *                          on the screen
  373.  *
  374.  *                 x      - This parameter defines the horizontal
  375.  *                          row on which the cursor will be placed.
  376.  *                          Consider "x" to be the "x" part of an
  377.  *                          "x,y" axis.
  378.  *
  379.  *                 y      - This parameter defines the vertical
  380.  *                          column on which the cursor will be placed.
  381.  *                          Consider "y" to be the "y" part of an
  382.  *                          "x,y" axis.
  383.  *
  384.  *
  385.  * Examples      : lpr_g_response(10,5,"Hit any key to continue : ");
  386.  *
  387.  * Rules         : The value input is ignored.
  388.  *
  389.  *                 The function return control to the colling modual as
  390.  *                 as soon as a any keyboard character is pressed.
  391.  *
  392.  *                 The "x" value must be between 1 and 24
  393.  *
  394.  *                 The "y" value must be between 1 and 80
  395.  *
  396.  */
  397.  
  398. lpr_g_response(x,y,string)
  399.  int x,y;
  400.  char string[];
  401.  
  402. { char *out_string;
  403.   printf("%c[%d;%dH",'\33',x,y);
  404.   printf("%s",string);
  405.   getch(out_string);
  406. }
  407.  
  408.  
  409. /* *******************************************************************
  410.  * Function name : lpr_g_yes_no(x, y, x_error, y_error, string,
  411.  *                              e_string, out_string)
  412.  *
  413.  * Description   : This function facilitates the input of a "y" or
  414.  *                 "n" value. Additionally, prior the to actual
  415.  *                 input, the cursor is placed at a specified screen
  416.  *                 location and a prompt is displayed. Also, if an
  417.  *                 invalid response is entered, an error message is
  418.  *                 displayed at a user defined screen location.
  419.  *
  420.  * Variables     : string - This variable is the vehicle used to
  421.  *                          receive the prompt that is displayed
  422.  *                          on the screen
  423.  *
  424.  *                 x      - This parameter defines the horizontal
  425.  *                          row on which the cursor will be placed.
  426.  *                          Consider "x" to be the "x" part of an
  427.  *                          "x,y" axis.
  428.  *
  429.  *                 y      - This parameter defines the vertical
  430.  *                          column on which the cursor will be placed.
  431.  *                          Consider "y" to be the "y" part of an
  432.  *                          "x,y" axis.
  433.  *
  434.  *                x_error - This parameter defines the horizontal
  435.  *                          row at which the error message is displayed.
  436.  *                          Consider "x" to be the "x" part of an
  437.  *                          "x,y" axis.
  438.  *
  439.  *                 y      - This parameter defines the vertical
  440.  *                          column at which the error message is displayed.
  441.  *                          Consider "y" to be the "y" part of an
  442.  *                          "x,y" axis.
  443.  *
  444.  *               e_string - This variable is used to pass the error
  445.  *                          message that will be displayed if an invalid
  446.  *                          response is entered.
  447.  *
  448.  *            out_string - "out_string" contains the yes or no response
  449.  *                         that is returned to the calling function.
  450.  *
  451.  * Examples      : char reply[2];
  452.  *                 lpr_g_yes_no(5,5,25,5,"Enter Y or N","ERROR, reenter",
  453.  *                               out_string);
  454.  *
  455.  * Rules         : The reply must be "y", "n", "Y", or "N"
  456.  *
  457.  *                 The "x" and "x_error" values must be between 1 and 24
  458.  *
  459.  *                 The "y" and "y_error" values must be between 1 and 80
  460.  *
  461.  */
  462.  
  463. lpr_g_yes_no(x,y,x_error,y_error,string,e_string,out_string)
  464.  int x,y,x_error,y_error;
  465.  char string[], e_string[], *out_string;
  466.  
  467. { do
  468.    {  printf("%c[%d;%dH",'\33',x,y);
  469.       printf("%s",string);
  470.       gets(out_string);
  471.       if ( *out_string != 'n' && *out_string != 'N' &&
  472.        *out_string != 'y' && *out_string != 'Y' )
  473.         {  printf("%c[%d;%dH",'\33',x_error,y_error);
  474.            printf("%s",e_string);
  475.         }
  476.    } while ( *out_string != 'n' && *out_string != 'N' &&
  477.          *out_string != 'y' && *out_string != 'Y' );
  478.  
  479. }
  480.  
  481.  
  482. /* *******************************************************************
  483.  * Function name : lpr_integer(x, y, string)
  484.  *
  485.  * Description   : This function facilitates the input of integer
  486.  *                 numbers. Additionally, prior the to actual
  487.  *                 input, the cursor is placed at a specified screen
  488.  *                 location and a prompt is displayed.
  489.  *
  490.  * Variables     : string - This variable is the vehicle used to
  491.  *                          receive the prompt that is displayed
  492.  *                          on the screen
  493.  *
  494.  *                 x      - This parameter defines the horizontal
  495.  *                          row on which the cursor will be placed.
  496.  *                          Consider "x" to be the "x" part of an
  497.  *                          "x,y" axis.
  498.  *
  499.  *                 y      - This parameter defines the vertical
  500.  *                          column on which the cursor will be placed.
  501.  *                          Consider "y" to be the "y" part of an
  502.  *                          "x,y" axis.
  503.  *
  504.  *
  505.  * Examples      : int output, lpr_intenger;
  506.  *                 output = lpr_integer(10,5,"Enter employee name : ");
  507.  *
  508.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  509.  *                 is converted as 123.
  510.  *
  511.  *                 The negative sign may be at either the beginning of
  512.  *                 ending of the input number.
  513.  *
  514.  *                 The function name "lpr_integer" may be optionally
  515.  *                 defined as an integer number within the calling
  516.  *                 function.
  517.  *
  518.  *                 The "x" value must be between 1 and 24
  519.  *
  520.  *                 The "y" value must be between 1 and 80
  521.  *
  522.  *                 Decimal points are ignored.
  523.  */
  524.  
  525. lpr_integer(x,y,string)
  526.  int x,y;
  527.  char string[];
  528.  
  529. { int out_num, i_convert();
  530.   char in_num[15];
  531.   printf("%c[%d;%dH",'\33',x,y);
  532.   printf("%s",string);
  533.   gets(in_num);
  534.   out_num = i_convert(in_num);
  535.   return(out_num);
  536. }
  537.  
  538. /* *******************************************************************
  539.  * Function name : l_char(x, y, out_string)
  540.  *
  541.  * Description   : This function facilitates the input of ASCII
  542.  *                 character strings. Additionally, prior the to actual
  543.  *                 input, the cursor is placed at a specified screen
  544.  *                 location.
  545.  *
  546.  * variables     : x      - This parameter defines the horizontal
  547.  *                          row on which the cursor will be placed.
  548.  *                          Consider "x" to be the "x" part of an
  549.  *                          "x,y" axis.
  550.  *
  551.  *                 y      - This parameter defines the vertical
  552.  *                          column on which the cursor will be placed.
  553.  *                          Consider "y" to be the "y" part of an
  554.  *                          "x,y" axis.
  555.  *
  556.  *             out_string - This variable contains the ASCII character
  557.  *                          character string input by the user.
  558.  *
  559.  *
  560.  * Examples      : char ascii_value[10];
  561.  *                 l_char(10,5,ascii_value);
  562.  *
  563.  * Rules         : Any ASCII characters can be entered.
  564.  *
  565.  *                 The "x" value must be between 1 and 24
  566.  *
  567.  *                 The "y" value must be between 1 and 80
  568.  *
  569.  */
  570.  
  571. l_char(x,y,out_string)
  572.  int x,y;
  573.  char  *out_string;
  574.  
  575. { printf("%c[%d;%dH",'\33',x,y);
  576.   gets(out_string);
  577. }
  578.  
  579.  
  580. /* *******************************************************************
  581.  * Function name : l_double(x,y)
  582.  *
  583.  * Description   : This function facilitates the input of double floating
  584.  *                 point number. Additionally, prior the to actual
  585.  *                 input, the cursor is placed at a specified screen
  586.  *                 location.
  587.  *
  588.  * Variables     : x      - This parameter defines the horizontal
  589.  *                          row on which the cursor will be placed.
  590.  *                          Consider "x" to be the "x" part of an
  591.  *                          "x,y" axis.
  592.  *
  593.  *                 y      - This parameter defines the vertical
  594.  *                          column on which the cursor will be placed.
  595.  *                          Consider "y" to be the "y" part of an
  596.  *                          "x,y" axis.
  597.  *
  598.  *
  599.  * Examples      : double output, l_double();
  600.  *                 output = l_double(10,5);
  601.  *
  602.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  603.  *                 is converted as 123.
  604.  *
  605.  *                 The negative sign may be at either the beginning of
  606.  *                 ending of the input number.
  607.  *
  608.  *                 The function name "l_double" must be defined
  609.  *                 as a double floating point number within the
  610.  *                 calling function.
  611.  *
  612.  *                 The "x" value must be between 1 and 24
  613.  *
  614.  *                 The "y" value must be between 1 and 80
  615.  *
  616.  */
  617.  
  618. double l_double(x,y)
  619.  int x,y;
  620.  
  621. { double out_num, d_convert();
  622.   char in_num[15];
  623.   printf("%c[%d;%dH",'\33',x,y);
  624.   gets(in_num);
  625.   out_num = d_convert(in_num);
  626.   return(out_num);
  627. }
  628.  
  629.  
  630. /* *******************************************************************
  631.  * Function name : l_float(x,y)
  632.  *
  633.  * Description   : This function facilitates the input of floating
  634.  *                 point number. Additionally, prior the to actual
  635.  *                 input, the cursor is placed at a specified screen
  636.  *                 location.
  637.  *
  638.  * Variables     : x      - This parameter defines the horizontal
  639.  *                          row on which the cursor will be placed.
  640.  *                          Consider "x" to be the "x" part of an
  641.  *                          "x,y" axis.
  642.  *
  643.  *                 y      - This parameter defines the vertical
  644.  *                          column on which the cursor will be placed.
  645.  *                          Consider "y" to be the "y" part of an
  646.  *                          "x,y" axis.
  647.  *
  648.  *
  649.  * Examples      : float output, l_float();
  650.  *                 output = l_float(10,5);
  651.  *
  652.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  653.  *                 is converted as 123.
  654.  *
  655.  *                 The negative sign may be at either the beginning of
  656.  *                 ending of the input number.
  657.  *
  658.  *                 The function name "l_float" must be defined
  659.  *                 as a double floating point number within the
  660.  *                 calling function.
  661.  *
  662.  *                 The "x" value must be between 1 and 24
  663.  *
  664.  *                 The "y" value must be between 1 and 80
  665.  *
  666.  */
  667.  
  668. float l_float(x,y)
  669.  int x,y;
  670.  
  671. { float out_num, f_convert();
  672.   char in_num[15];
  673.   printf("%c[%d;%dH",'\33',x,y);
  674.   gets(in_num);
  675.   out_num = f_convert(in_num);
  676.   return(out_num);
  677. }
  678.  
  679.  
  680. /* *******************************************************************
  681.  * Function name : l_g_response(x,y)
  682.  *
  683.  * Description   : This function facilitates the input of a keyboard
  684.  *                 response. Additionally, prior the to actual
  685.  *                 input, the cursor is placed at a specified screen
  686.  *                 location.
  687.  *
  688.  * Variables     : x      - This parameter defines the horizontal
  689.  *                          row on which the cursor will be placed.
  690.  *                          Consider "x" to be the "x" part of an
  691.  *                          "x,y" axis.
  692.  *
  693.  *                 y      - This parameter defines the vertical
  694.  *                          column on which the cursor will be placed.
  695.  *                          Consider "y" to be the "y" part of an
  696.  *                          "x,y" axis.
  697.  *
  698.  *
  699.  * Examples      : l_g_response(10,5);
  700.  *
  701.  * Rules         : The value input is ignored.
  702.  *
  703.  *                 The function return control to the calling modual as
  704.  *                 as soon as a any keyboard character is pressed.
  705.  *
  706.  *                 The "x" value must be between 1 and 24
  707.  *
  708.  *                 The "y" value must be between 1 and 80
  709.  *
  710.  */
  711.  
  712. l_g_response(x,y)
  713.  int x,y;
  714.  
  715. { char *out_string;
  716.   printf("%c[%d;%dH",'\33',x,y);
  717.   getch(out_string);
  718. }
  719.  
  720.  
  721. /* *******************************************************************
  722.  * Function name : l_g_yes_no(x, y, x_error, y_error, e_string,
  723.  *                            out_string)
  724.  *
  725.  * Description   : This function facilitates the input of a "y" or
  726.  *                 "n" value. Additionally, prior the to actual
  727.  *                 input, the cursor is placed at a specified screen
  728.  *                 location and a prompt is displayed. Also, if an
  729.  *                 invalid response is entered, an error message is
  730.  *                 displayed.
  731.  *
  732.  * Variables     : x      - This parameter defines the horizontal
  733.  *                          row on which the cursor will be placed.
  734.  *                          Consider "x" to be the "x" part of an
  735.  *                          "x,y" axis.
  736.  *
  737.  *                 y      - This parameter defines the vertical
  738.  *                          column on which the cursor will be placed.
  739.  *                          Consider "y" to be the "y" part of an
  740.  *                          "x,y" axis.
  741.  *
  742.  *                x_error - This parameter defines the horizontal
  743.  *                          row at which the error message is displayed.
  744.  *                          Consider "x" to be the "x" part of an
  745.  *                          "x,y" axis.
  746.  *
  747.  *                 y      - This parameter defines the vertical
  748.  *                          column at which the error message is displayed.
  749.  *                          Consider "y" to be the "y" part of an
  750.  *                          "x,y" axis.
  751.  *
  752.  *               e_string - This variable is used to pass the error
  753.  *                          message that will be displayed if an invalid
  754.  *                          response is entered.
  755.  *
  756.  *            out_string - "out_string" contains the yes or no response
  757.  *                         that is returned to the calling function.
  758.  *
  759.  * Examples      : char reply[2];
  760.  *                 l_g_yes_no(5,5,25,5,"ERROR, reenter", out_string);
  761.  *
  762.  * Rules         : The reply must be "y", "n", "Y", or "N"
  763.  *
  764.  *                 The "x" and "x_error" values must be between 1 and 24
  765.  *
  766.  *                 The "y" and "y_error" values must be between 1 and 80
  767.  *
  768.  */
  769.  
  770. l_g_yes_no(x, y, x_error, y_error, e_string, out_string)
  771.  int x,y,x_error,y_error;
  772.  char e_string[], *out_string;
  773.  
  774. { do
  775.    {  printf("%c[%d;%dH",'\33',x,y);
  776.       gets(out_string);
  777.       if ( *out_string != 'n' && *out_string != 'N' &&
  778.        *out_string != 'y' && *out_string != 'Y' )
  779.         {  printf("%c[%d;%dH",'\33',x_error,y_error);
  780.            printf("%s",e_string);
  781.         }
  782.    } while ( *out_string != 'n' && *out_string != 'N' &&
  783.          *out_string != 'y' && *out_string != 'Y' );
  784.  
  785. }
  786.  
  787.  
  788. /* *******************************************************************
  789.  * Function name : l_integer(x,y)
  790.  *
  791.  * Description   : This function facilitates the input of integer
  792.  *                 numbers. Additionally, prior the to actual
  793.  *                 input, the cursor is placed at a specified screen
  794.  *                 location.
  795.  *
  796.  * Variables     : x      - This parameter defines the horizontal
  797.  *                          row on which the cursor will be placed.
  798.  *                          Consider "x" to be the "x" part of an
  799.  *                          "x,y" axis.
  800.  *
  801.  *                 y      - This parameter defines the vertical
  802.  *                          column on which the cursor will be placed.
  803.  *                          Consider "y" to be the "y" part of an
  804.  *                          "x,y" axis.
  805.  *
  806.  *
  807.  * Examples      : int output, l_intenger;
  808.  *                 output = l_integer(10,5);
  809.  *
  810.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  811.  *                 is converted as 123.
  812.  *
  813.  *                 The negative sign may be at either the beginning of
  814.  *                 ending of the input number.
  815.  *
  816.  *                 The function name "l_integer" may be optionally
  817.  *                 defined as an integer number within the calling
  818.  *                 function.
  819.  *
  820.  *                 The "x" value must be between 1 and 24
  821.  *
  822.  *                 The "y" value must be between 1 and 80
  823.  *
  824.  *                 Decimal points are ignored.
  825.  */
  826.  
  827. l_integer(x,y,)
  828.  int x,y;
  829.  
  830. { int out_num, i_convert();
  831.   char in_num[15];
  832.   printf("%c[%d;%dH",'\33',x,y);
  833.   gets(in_num);
  834.   out_num = i_convert(in_num);
  835.   return(out_num);
  836. }
  837.  
  838.  
  839. /* *******************************************************************
  840.  * Function name : pr_char(string, outstring)
  841.  *
  842.  * Description   : This function facilitates the input of ASCII
  843.  *                 character strings. Additionally, prior to the
  844.            actual input, a specified prompt is displayed.
  845.  *
  846.  * Variables     : string - This variable is the vehicle used to
  847.  *                          receive the prompt that is displayed
  848.  *                          on the screen
  849.  *
  850.  *              outstring - This variable contains the ASCII character
  851.  *                          character string input by the user.
  852.  *
  853.  *
  854.  * Examples      : char ascii_value[10];
  855.  *                 pr_char("Enter employee name : ",ascii_value);
  856.  *
  857.  * Rules         : Any ASCII characters can be entered.
  858.  *
  859.  */
  860.  
  861. pr_char(string,out_string)
  862.  char string[], *out_string;
  863.  
  864. { printf("%s",string);
  865.   gets(out_string);
  866. }
  867.  
  868.  
  869. /* *******************************************************************
  870.  * Function name : pr_double(string)
  871.  *
  872.  * Description   : This function facilitates the input of double floating
  873.  *                 point number. Additionally, prior the to actual
  874.  *                 input, a specified prompt is displayed.
  875.  *
  876.  * Variables     : string - This variable is the vehicle used to
  877.  *                          receive the prompt that is displayed
  878.  *                          on the screen
  879.  *
  880.  * Examples      : double output, pr_double();
  881.  *                 output = lpr_double("Enter employee name : ");
  882.  *
  883.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  884.  *                 is converted as 123.
  885.  *
  886.  *                 The negative sign may be at either the beginning of
  887.  *                 ending of the input number.
  888.  *
  889.  *                 The function name "pr_double" must be defined
  890.  *                 as a double floating point number within the
  891.  *                 calling function.
  892.  *
  893.  */
  894.  
  895. double pr_double(string)
  896.  char string[];
  897.  
  898. { double out_num, d_convert();
  899.   char in_num[15];
  900.   printf("%s",string);
  901.   gets(in_num);
  902.   out_num = d_convert(in_num);
  903.   return(out_num);
  904. }
  905.  
  906.  
  907. /* *******************************************************************
  908.  * Function name : pr_float(string)
  909.  *
  910.  * Description   : This function facilitates the input of floating
  911.  *                 point number. Additionally, prior the to actual
  912.  *                 input, a specified prompt is displayed.
  913.  *
  914.  * Variables     : string - This variable is the vehicle used to
  915.  *                          receive the prompt that is displayed
  916.  *                          on the screen
  917.  *
  918.  * Examples      : float output, pr_float();
  919.  *                 output = pr_float("Enter employee name : ");
  920.  *
  921.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  922.  *                 is converted as 123.
  923.  *
  924.  *                 The negative sign may be at either the beginning of
  925.  *                 ending of the input number.
  926.  *
  927.  *                 The function name "pr_float" must be defined
  928.  *                 as a double floating point number within the
  929.  *                 calling function.
  930.  *
  931.  */
  932.  
  933. float pr_float(string)
  934.  char string[];
  935.  
  936. { float out_num, f_convert();
  937.   char in_num[15];
  938.   printf("%s",string);
  939.   gets(in_num);
  940.   out_num = f_convert(in_num);
  941.   return(out_num);
  942. }
  943.  
  944.  
  945.  
  946. /* *******************************************************************
  947.  * Function name : pr_g_response(string)
  948.  *
  949.  * Description   : This function facilitates the input of a keyboard
  950.  *                 response. Additionally, prior the to actual
  951.  *                 input, a specified prompt is displayed.
  952.  *
  953.  * Variables     : string - This variable is the vehicle used to
  954.  *                          receive the prompt that is displayed
  955.  *                          on the screen
  956.  *
  957.  *
  958.  * Examples      : pr_g_response("Hit any key to continue : ");
  959.  *
  960.  * Rules         : The value input is ignored.
  961.  *
  962.  *                 The function return control to the colling modual as
  963.  *                 as soon as a any keyboard character is pressed.
  964.  *
  965.  */
  966.  
  967. pr_g_response(string)
  968.  char string[];
  969.  
  970. { char *out_string;
  971.   printf("%s",string);
  972.   getch(out_string);
  973. }
  974.  
  975.  
  976. /* *******************************************************************
  977.  * Function name : pr_g_yes_no(string, e_string, out_string)
  978.  *
  979.  * Description   : This function facilitates the input of a "y" or
  980.  *                 "n" value. Additionally, prior the to actual
  981.  *                 input, a specified prompt is displayed. Also, if an
  982.  *                 invalid response is entered, an error message is
  983.  *                 displayed.
  984.  *
  985.  * Variables     : string - This variable is the vehicle used to
  986.  *                          receive the prompt that is displayed
  987.  *                          on the screen
  988.  *
  989.  *               e_string - This variable is used to pass the error
  990.  *                          message that will be displayed if an invalid
  991.  *                          response is entered.
  992.  *
  993.  *            out_string - "out_string" contains the yes or no response
  994.  *                         that is returned to the calling function.
  995.  *
  996.  * Examples      : char reply[2];
  997.  *                 pr_g_yes_no("Enter Y or N","ERROR, reenter",out_string);
  998.  *
  999.  * Rules         : The reply must be "y", "n", "Y", or "N"
  1000.  *
  1001.  */
  1002.  
  1003. pr_g_yes_no(string,e_string,out_string)
  1004.  char string[], e_string[], *out_string;
  1005.  
  1006. { do
  1007.    {  printf("%s",string);
  1008.       gets(out_string);
  1009.       if ( *out_string != 'n' && *out_string != 'N' &&
  1010.        *out_string != 'y' && *out_string != 'Y' )
  1011.         {  printf("\n%s",e_string);
  1012.         }
  1013.    } while ( *out_string != 'n' && *out_string != 'N' &&
  1014.          *out_string != 'y' && *out_string != 'Y' );
  1015.  
  1016. }
  1017.  
  1018.  
  1019. /* *******************************************************************
  1020.  * Function name : pr_integer(string)
  1021.  *
  1022.  * Description   : This function facilitates the input of integer
  1023.  *                 numbers. Additionally, prior the to actual
  1024.  *                 input, a specified prompt is displayed.
  1025.  *
  1026.  * Variables     : string - This variable is the vehicle used to
  1027.  *                          receive the prompt that is displayed
  1028.  *                          on the screen
  1029.  *
  1030.  *                          "x,y" axis.
  1031.  *
  1032.  * Examples      : int output, pr_intenger;
  1033.  *                 output = pr_integer("Enter employee name : ");
  1034.  *
  1035.  * Rules         : Non-numeric values are ignored, thus the value 12z3
  1036.  *                 is converted as 123.
  1037.  *
  1038.  *                 The negative sign may be at either the beginning of
  1039.  *                 ending of the input number.
  1040.  *
  1041.  *                 The function name "pr_integer" may be optionally
  1042.  *                 defined as an integer number within the calling
  1043.  *                 function.
  1044.  *
  1045.  *                 Decimal points are ignored.
  1046.  */
  1047.  
  1048. pr_integer(string)
  1049.  char string[];
  1050.  
  1051. { int out_num, i_convert();
  1052.   char in_num[15];
  1053.   printf("%s",string);
  1054.   gets(in_num);
  1055.   out_num = i_convert(in_num);
  1056.   return(out_num);
  1057. }
  1058.  
  1059.